home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / slocate.preinst < prev    next >
Encoding:
Text File  |  2007-02-21  |  5.3 KB  |  197 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. suffix=notslocate
  6. #SL_DEBUG=echo 
  7.  
  8. #echo "DEBUG========================"
  9. #dpkg-divert --list slocate
  10. #echo "============================="
  11.  
  12. # check for diversions...
  13. divs=`dpkg-divert --list slocate`
  14. if [ "$divs" != "" ]
  15. then
  16.     
  17.     # remove links
  18.     for i in /usr/bin/locate /usr/bin/updatedb
  19.     do
  20.         old_div=`echo $divs |grep $i || true`
  21.         # check for links
  22.         if [ -f $i -a "`readlink $i`" != "" ]
  23.         then
  24.             $SL_DEBUG rm $i
  25.         else
  26.         # Handle special case where /usr/bin/locate is not a symlink
  27.         # to /usr/bin/slocate but a diversion exists.
  28.  
  29.             # We MUST have a $i.old or $i.$suffix.
  30.             if [ -f $i.old -o -f $i.$suffix ]
  31.             then
  32.                 $SL_DEBUG rm $i
  33.             fi
  34.         fi
  35.  
  36.         if [ -f $i.old ]
  37.         then
  38.             $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  39.             --divert $i.old $i
  40.         fi
  41.         if [ -f $i.$suffix ]
  42.         then
  43.             $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  44.             --divert $i.$suffix $i
  45.         fi
  46.       done
  47.  
  48.     old_div=`echo $divs |grep usr/share/man/man1/updatedb || true`
  49.     if [ "$old_div" != "" ]
  50.     then
  51.         if [ -f /usr/share/man/man1/updatedb.1.gz ]
  52.         then
  53.             $SL_DEBUG rm /usr/share/man/man1/updatedb.1.gz
  54.         fi
  55.         if [ -f /usr/share/man/man1/updatedb.$suffix.1.gz ]
  56.         then
  57.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  58.             --divert /usr/share/man/man1/updatedb.$suffix.1.gz \
  59.             /usr/share/man/man1/updatedb.1.gz
  60.         fi
  61.         if [ -f /usr/share/man/man1/updatedb.1.gz.old ]
  62.         then
  63.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  64.             --divert /usr/share/man/man1/updatedb.1.gz.old \
  65.             /usr/share/man/man1/updatedb.1.gz
  66.         fi
  67.     fi
  68.     old_div=`echo $divs |grep usr/man/man1/updatedb || true`
  69.     if [ "$old_div" != "" ]
  70.     then
  71.         if [ -f /usr/man/man1/updatedb.1.gz ]
  72.         then
  73.             $SL_DEBUG rm /usr/man/man1/updatedb.1.gz
  74.         fi
  75.         #if [ -f /usr/man/man1/updatedb.1.gz.old ]
  76.         #then
  77.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  78.             --divert /usr/man/man1/updatedb.1.gz.old \
  79.             /usr/man/man1/updatedb.1.gz
  80.         #fi
  81.     fi
  82.  
  83.     old_div=`echo $divs | grep usr/man/man1/locate || true`
  84.     if [ "$old_div" != "" ]
  85.     then
  86.         if [ -f /usr/man/man1/locate.1.gz ]
  87.         then
  88.             $SL_DEBUG rm /usr/man/man1/locate.1.gz
  89.         fi
  90.         #if [ -f /usr/man/man1/locate.1.gz.old ]
  91.         #then
  92.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  93.             --divert /usr/man/man1/locate.1.gz.old \
  94.             /usr/man/man1/locate.1.gz
  95.         #fi
  96.     fi
  97.     old_div=`echo $divs | grep usr/share/man/man1/locate || true`
  98.     if [ "$old_div" != "" ]
  99.     then
  100.         if [ -f /usr/share/man/man1/locate.1.gz ]
  101.         then
  102.             $SL_DEBUG rm /usr/share/man/man1/locate.1.gz
  103.         fi
  104.         if [ -f /usr/share/man/man1/locate.$suffix.1.gz ]
  105.         then
  106.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  107.             --divert /usr/share/man/man1/locate.$suffix.1.gz \
  108.             /usr/share/man/man1/locate.1.gz
  109.         fi
  110.         if [ -f /usr/share/man/man1/locate.1.gz.old ]
  111.         then
  112.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  113.             --divert /usr/share/man/man1/locate.1.gz.old \
  114.             /usr/share/man/man1/locate.1.gz
  115.         fi
  116.     fi
  117.  
  118.     old_div=`echo $divs | grep /etc/cron.daily/find || true`
  119.     if [ "$old_div" != "" -a ! -f /etc/cron.daily.find.$suffix ]
  120.     then
  121.         if [ -f /etc/cron.daily/find.old ]
  122.         then
  123.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  124.             --divert /etc/cron.daily/find.old \
  125.             /etc/cron.daily/find
  126.         fi
  127.         if [ -f /etc/cron.daily/find.$suffix ]
  128.         then
  129.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  130.             --divert /etc/cron.daily/find.$suffix \
  131.             /etc/cron.daily/find
  132.         fi
  133.         if [ ! -f /etc/cron.daily/find ]
  134.         then
  135.         # no idea how this happened
  136.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  137.             --divert /etc/cron.daily/find.$suffix \
  138.             /etc/cron.daily/find
  139.         fi
  140.     fi
  141.  
  142.     # the cron.daily/find must be divered to /etc/<something> so that
  143.     # it is no longer run by cron.
  144.     old_div=`echo $divs | grep /etc/cron.daily.find.$suffix || true`
  145.     if [ "$old_div" != "" ]
  146.     then
  147.         if [ -f /etc/cron.daily.find.$suffix ]
  148.         then
  149.         $SL_DEBUG dpkg-divert --package slocate --remove --rename \
  150.             --divert /etc/cron.daily.find.$suffix \
  151.             /etc/cron.daily/find
  152.         fi
  153.     fi
  154.     
  155. fi
  156.  
  157. # all diverts should be toast
  158. if [ "`dpkg-divert --list slocate`" != "" ]
  159. then
  160.     echo "==============================================="
  161.     echo "===Error. The following diversions still exist:"
  162.     dpkg-divert --list slocate
  163.     echo "==============================================="
  164.     exit 1
  165. fi
  166.  
  167. #if [ install = "$1" ]; then
  168.     $SL_DEBUG dpkg-divert --package slocate --add --rename \
  169.         --divert /usr/bin/locate.$suffix \
  170.             /usr/bin/locate
  171.     $SL_DEBUG dpkg-divert --package slocate --add --rename \
  172.         --divert /usr/bin/updatedb.$suffix \
  173.             /usr/bin/updatedb
  174.     $SL_DEBUG dpkg-divert --package slocate --add --rename \
  175.         --divert /usr/share/man/man1/locate.$suffix.1.gz \
  176.             /usr/share/man/man1/locate.1.gz
  177.     $SL_DEBUG dpkg-divert --package slocate --add --rename \
  178.         --divert /usr/share/man/man1/updatedb.$suffix.1.gz \
  179.             /usr/share/man/man1/updatedb.1.gz
  180.     # The cron script must be moved out of cron.daily so that it is
  181.     # no longer run.
  182.     $SL_DEBUG dpkg-divert --package slocate --add --rename \
  183.         --divert /etc/cron.daily/find.$suffix \
  184.             /etc/cron.daily/find
  185. #fi
  186.  
  187. # The database format has changed, check if we should remove it.
  188. if [ "upgrade" = "$1" -a -e "/var/lib/slocate/slocate.db" -a "$2" = "2.7-4" ] ; then
  189.     rm -f /var/lib/slocate/slocate.db
  190.     echo
  191.     echo "The slocate database format has changed. It will no longer function with"
  192.     echo "this version of Secure Locate and has been removed."
  193.     echo
  194. fi
  195.  
  196.  
  197.